<%--
  Created by IntelliJ IDEA.
  User: zhuangjianhui_91
  Date: 2015/10/13
  Time: 14:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" import="java.util.*" language="java" %>
<html>
<head>
    <title></title>
</head>
<body>
<center>
    <h2>HTTP Header Request Example</h2>
    <table width="100%" border="1" align="center">
        <tr bgcolor="#949494">
            <th>Header Name</th>
            <th>Header Value(s)</th>
        </tr>
        <%
            Enumeration headerNames = request.getHeaderNames();
            while (headerNames.hasMoreElements()) {
                String paramName = (String) headerNames.nextElement();
                out.print("<tr><td>" + paramName + "</td>\n");
                String paramValue = request.getHeader(paramName);
                out.println("<td> " + paramValue + "</td></tr>\n");
            }
        %>
    </table>
    <%
        out.print("sessionId" + request.getSession().getId());
    %>

    <center>
        <h2>HTTP Header response Example</h2>
        <%
            // 设置每隔5秒自动刷新
            response.setIntHeader("Refresh", 5);
            // 获取当前时间
            Calendar calendar = new GregorianCalendar();
            String am_pm;
            int hour = calendar.get(Calendar.HOUR);
            int minute = calendar.get(Calendar.MINUTE);
            int second = calendar.get(Calendar.SECOND);
            if (calendar.get(Calendar.AM_PM) == 0)
                am_pm = "AM";
            else
                am_pm = "PM";
            String CT = hour + ":" + minute + ":" + second + " " + am_pm;
            out.println("Current Time is: " + CT + "\n");
        %>
    </center>

</center>
</body>
</html>
